﻿<%@ Page Title="NM软件平台" Language="C#" MasterPageFile="~/master/m.master" %>

<script runat="server">
    
</script>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
<link rel="stylesheet" href="assets/css/index.css" />
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="main" runat="Server">
    <div id="wrapper">
        <!--左侧导航开始-->
        <nav class="navbar-default navbar-static-side" role="navigation">
            <div class="nav-close">
                <i class="fa fa-times-circle"></i>
            </div>
            <div class="sidebar-collapse">
                <ul class="nav" id="side-menu">
                    <li class="nav-header">
                        <div class="dropdown profile-element">
							<img alt="image" class="img-circle avatar" src="assets/img/NOME-logo.png" />
                            <a data-toggle="dropdown" class="dropdown-toggle" href="#">
                                <span class="clear">
                                    <span class="block m-t-xs"><strong class="font-bold loginName">游客</strong></span>
                                    <span class="text-muted text-xs block"><span class="loginRole">角色</span><b class="caret"></b></span>
                                </span>
                            </a>
                            <ul class="dropdown-menu animated fadeInRight m-t-xxs">
                                <li>
                                    <a id="personalInfo" class="J_menuItem" href="system/EditUser.aspx">个人资料</a>
                                </li>
                                  <li>
                                    <a id="SetPassPtn" href="#">修改密码</a>
                                </li>
                                <li class="divider"></li>
                                <li>
                                    <a href="#" class="btn-outLogin">安全退出</a>
                                </li>
                            </ul>
                        </div>
                        <div class="logo-element">
                            NM+
                        </div>
                    </li>
                    <li class="hide">
                        <a class="J_menuItem" id="addUserTab" href="system/AddUser.aspx">
                            <span class="nav-label">添加用户</span>
                        </a>
                    </li>
                    <li class="hide">
                        <a class="J_menuItem" id="eidtUserTab" href="system/EidtUser.aspx">
                            <span class="nav-label">编辑用户</span>
                        </a>
                    </li>
                    <li class="hide">
                        <a class="J_menuItem" id="addDisplayInfoTab" href="shelf/AddDisplayInfo.aspx">
                            <span class="nav-label">添加货架陈列信息</span>
                        </a>
                    </li>
                    <li class="hide">
                        <a class="J_menuItem" id="editDisplayInfoTab" href="shelf/EditDisplayInfo.aspx">
                            <span class="nav-label">编辑货架陈列信息</span>
                        </a>
                    </li>
                     <li class="hide">
                        <a class="J_menuItem" id="addShopTab" href="shelf/AddShop.aspx">
                            <span class="nav-label">添加店铺基本信息</span>
                        </a>
                    </li>
                    <li class="hide">
                        <a class="J_menuItem" id="editShopTab" href="shelf/EidtShop.aspx">
                            <span class="nav-label">编辑店铺基本信息</span>
                        </a>
                    </li>
                    <li class="hide">
                        <a class="J_menuItem" id="printBalance">
                            <span class="nav-label">结算打印预览</span>
                        </a>
                    </li>
                </ul>
            </div>
        </nav>
        <!--左侧导航结束-->
        <!--右侧部分开始-->
        <div id="page-wrapper" class="gray-bg dashbard-1">
            <div class="row">
                <nav class="navbar navbar-static-top" role="navigation" style="margin-bottom: 0; overflow: hidden;">
                    <div class="navbar-header">
                        <a class="navbar-minimalize minimalize-styl-2 btn btn-primary " href="#">
                            <i class="fa fa-bars"></i>
                        </a>
                        <div role="search" class="navbar-form-custom hide">
                            <div class="form-group">
                                <input type="text" placeholder="请输入您需要查找的内容 …" class="form-control" name="top-search" id="top-search">
                            </div>
                        </div>
                    </div>
                    <ul class="nav navbar-top-links navbar-right" style="height: 42px;">
                        <li class="dropdown">
                            <a class="dropdown-toggle count-info" data-toggle="dropdown" href="#">
                                <i class="fa fa-envelope"></i><span class="label label-warning">0</span>
                            </a>
                            <ul class="dropdown-menu dropdown-messages">
                                <li class="m-t-xs">
                                    <div class="dropdown-messages-box">
                                        <a href="profile.html" class="pull-left">
                                            <img alt="image" class="img-circle" src="../assets/img/a7.jpg">
                                        </a>
                                        <div class="media-body">
                                            <small class="pull-right">46小时前</small>
                                            <strong>小四</strong> 这个在日本投降书上签字的军官，建国后一定是个不小的干部吧？
											<br>
                                            <small class="text-muted">3天前 2014.11.8</small>
                                        </div>
                                    </div>
                                </li>
                            </ul>
                        </li>
                        <li class="dropdown">
                            <a class="dropdown-toggle count-info" data-toggle="dropdown" href="#">
                                <i class="fa fa-bell"></i><span class="label label-primary">0</span>
                            </a>
                            <ul class="dropdown-menu dropdown-alerts">
                                <li>
                                    <a href="mailbox.html">
                                        <div>
                                            <i class="fa fa-envelope fa-fw"></i>您有0条未读消息
											<span class="pull-right text-muted small">4分钟前</span>
                                        </div>
                                    </a>
                                </li>
                            </ul>
                        </li>
                        <li class="hidden-xs hide">
                            <a href="index_v1.html" class="J_menuItem" data-index="0"><i class="fa fa-cart-arrow-down"></i></a>
                        </li>
                        <li class="dropdown hidden-xs">
                            <a class="right-sidebar-toggle" aria-expanded="false">
                                <i class="fa fa-tasks"></i>通知
                            </a>
                        </li>
                    </ul>
                </nav>
            </div>
            <div class="row content-tabs">
                <button class="roll-nav roll-left J_tabLeft">
                    <i class="fa fa-backward"></i>
                </button>
                <nav class="page-tabs J_menuTabs">
                    <div class="page-tabs-content">
                        <a href="javascript:;" class="active J_menuTab" data-id="index_v2.aspx">首页</a>
                    </div>
                </nav>
                <button class="roll-nav roll-right J_tabRight">
                    <i class="fa fa-forward"></i>
                </button>
                <div class="btn-group roll-nav roll-right">
                    <button class="dropdown J_tabClose" data-toggle="dropdown">
                        关闭操作<span class="caret"></span>

                    </button>
                    <ul role="menu" class="dropdown-menu dropdown-menu-right">
                        <li class="J_tabShowActive">
                            <a>定位当前选项卡</a>
                        </li>
                        <li class="divider"></li>
                        <li class="J_tabCloseAll">
                            <a>关闭全部选项卡</a>
                        </li>
                        <li class="J_tabCloseOther">
                            <a>关闭其他选项卡</a>
                        </li>
                    </ul>
                </div>
                <a href="#" class="roll-nav roll-right J_tabExit"><i class="fa fa fa-sign-out"></i>退出</a>
            </div>
            <div class="row J_mainContent" id="content-main">
                <iframe class="J_iframe" name="iframe0" width="100%" height="100%" src="index_v2.aspx" frameborder="0" data-id="index_v2.aspx" seamless></iframe>
            </div>
            <div class="footer">
                <div class="pull-left companyName" style="padding-left:5px;"></div>
                <div class="text-center">
                    &copy;CopyRight 2016-2017 By
					<a href="http://www.km-china.cn/" target="_blank">NM+</a>
                </div>
            </div>
        </div>
        <!--右侧部分结束-->
        <!--右侧边栏开始-->
        <div id="right-sidebar">
            <div class="sidebar-container">

                <ul class="nav nav-tabs navs-2">
                    <li class="active">
                        <a data-toggle="tab" href="#tab-1">
                            <i class="fa fa-gear"></i>通知
                        </a>
                    </li>
                    <li>
                        <a data-toggle="tab" href="#tab-2">项目进度
                        </a>
                    </li>
                </ul>

                <div class="tab-content">
                    <div id="tab-1" class="tab-pane active">
                        <div class="sidebar-title">
                            <h3><i class="fa fa-comments-o"></i>最新通知</h3>
                            <small><i class="fa fa-tim"></i>您当前有0条未读信息</small>
                        </div>

                        <div>
                        </div>
                        <div id="tab-2" class="tab-pane">
                            <div class="sidebar-title">
                                <h3><i class="fa fa-cube"></i>最新任务</h3>
                                <small><i class="fa fa-tim"></i>您当前有0个任务，1个已完成</small>
                            </div>

                            <ul class="sidebar-list">
                            </ul>

                        </div>
                    </div>

                </div>
            </div>
            <!--右侧边栏结束-->
            <!--mini聊天窗口开始-->

            <div id="small-chat" class="hide">
                <span class="badge badge-warning pull-right">5</span>
                <a class="open-small-chat">
                    <i class="fa fa-comments"></i>
                </a>
            </div>
           <%-- <div id="resetPswWindow" style="padding: 8px;">
                <form id="checkPswForm" method="get" action="#">
                    <div>
                        <table class="module-info" cellpadding="0" cellspacing="0">
                            <thead></thead>
                            <tbody>
                                <tr>
                                    <td colspan="2" style="padding-bottom: 8px;">
                                        <label class="control-label col-sp">原密码</label>
                                        <input type="password" id="oldPsw" name="oldPsw"
                                            class="form-control" />
                                    </td>
                                </tr>
                                <tr>
                                    <td colspan="2" style="padding-bottom: 8px;">
                                        <label class="control-label col-sp">新密码</label>
                                        <input type="password" id="newPsw" name="newPsw"
                                            class="form-control" />
                                    </td>
                                </tr>
                                <tr>
                                    <td colspan="2">
                                        <label class="control-label col-sp">密码确认</label>
                                        <input type="password" id="newPswSnd" name="newPswSnd"
                                            class="form-control" />
                                    </td>
                                </tr>
                            </tbody>
                        </table>

                    </div>
                </form>
            </div>--%>
        </div>
   </div>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="footer" runat="server">
    <script src="assets/js/plugins/validate/jquery.validate.min.js"></script>
    <script src="assets/js/plugins/validate/messages_zh.min.js"></script>
   <%-- <script src="https://dn-bts.qbox.me/sdk/bugtags-1.0.3.js"></script>
    <script>
        // VERSION_NAME 替换为项目的版本，VERSION_CODE 替换为项目的子版本
        new Bugtags('9a83c887c92e651ad2b43c53887848c9', '1128', '1.0.0.1');
    </script>--%>
    <script type="application/javascript">
        $(document).ready(function () {
            //检测是否已登录
            if (Y.checkNull(window.sessionStorage.getItem('login-info'))) {
                top.location.href = 'login.aspx';
            }
            else {
                var data = sessionStorage.getItem('login-info');
                var d = $.parseJSON(data);
                if (!Y.checkNull(d.Avatar))
                    $(".avatar").attr("src", d.Avatar);
                if (!Y.checkNull(d.NickName))
                    $(".loginName").text(d.NickName);
                if (!Y.checkNull(d.CompanyName))
                    $(".companyName").text(d.CompanyName);
                if (!Y.checkNull(d.RoleName))
                    $(".loginRole").text(d.RoleName);
                if (!Y.checkNull(d.UserId)){
                	var tempUrl = $('#personalInfo').attr('href');
                	$('#personalInfo').attr('href', tempUrl + '?id=' + d.UserId);
                }
                if (d.IsModifyPass) {
                    showdialog(1);
                }
                //预留部门ID
                //d.DeptId
            }
            function showdialog(type) {
                //iframe层
                layer.open({
                    type: 2,
                    title: '修改密码,当前账号:' + d.NickName,
                    shadeClose: false,
                    shade: 0.8,
                    area: ['40%', '38%'],
                    content: 'system/ModifyPass.aspx?type='+type //iframe的url

                });
            }

			//头像出错时
            $('.avatar').error(function(){
  				$(this).attr('src','assets/img/default_head.jpg');
			});

            $('.J_tabExit,.btn-outLogin').click(function () {
                //退出
                //TODO:调api清除session
                swal({
                    title: '确定要退出系统吗？',
                    type: 'warning',
                    showCancelButton: true,
                    confirmButtonColor: '#DD6B55',
                    confirmButtonText: '确定',
                    cancelButtonText: '留下',
                }, function () {
                    var data = sessionStorage.getItem('login-info');
                    var d = $.parseJSON(data);
                    if (!Y.checkNull(d.OnlineInfo) &&
                        !Y.checkNull(d.OnlineInfo.UserID) &&
                        !Y.checkNull(d.OnlineInfo.Token)) {
                        window.sessionStorage.removeItem('login-info');
                        top.location.href = "login.aspx?CheckOnline=true&RemoveToken=true&userid=" + d.OnlineInfo.UserID +
                                                                               "&token=" + d.OnlineInfo.Token;
                    }
                    else {
                        window.sessionStorage.removeItem('login-info');
                        top.location.href = "login.aspx?CheckOnline=true";
                    }
                });
            });

            $('#SetPassPtn').click(function () {
                showdialog(0);
                //layer.confirm('要修改密码吗？', {
                //    type: 1,
                //    title: '修改密码',
                //    content: $('#resetPswWindow'), //捕获的元素
                //    btn: ['确定', '取消'], //按钮
                //    shade:false, //不显示遮罩
                //}, function () {
                //    //检验重置密码
                //    $('#checkPswForm').submit();
                //}, function () {
                //});
            });
            //$('#checkPswForm').validate({
            //    rules: {
            //        oldPsw: {
            //            required: true
            //        },
            //        newPsw: {
            //            required: true
            //        },
            //        newPswSnd: {
            //            required: true,
            //            equalTo: "#newPsw"
            //        }
            //    },
            //    submitHandler: function () {
            //        //检验通过后执行密码重置
            //        Y.API2('Users', 'SetPass', {
            //            oldPass: md5($('#oldPsw').val()),
            //            newPass: md5($('#newPsw').val()),
            //            newPassRepeated: md5($('#newPswSnd').val())
            //        }, function (data) {
            //            layer.closeAll('dialog');
            //            if (data.Success == false) {
            //            	swal(data.Message, '', 'error');
            //            } else {
            //            	swal('修改成功', '', 'success');
            //                //关闭弹框
            //                $('#closeResetPswBox').click();
            //            }
            //        });
            //    }
            //});

            //加载菜单
            var icons = ['home','cubes','database','wrench','table','cart-plus'];
            var loadList = function () {
                layer.msg('玩命加载中……', {icon: 16, shade: 0.5, time:0, maxWidth:200});
                Y.API3('Right', 'GetModule', {}, function (data) {
                    if (!Y.checkNull(data) && data.length > 0) {
                        //json处理
                        var html = "";
                        var c_html = "";
                        data.map(function (item,i) {
                            //console.log(item.ModuleName);
                            html += '<li>'
                                    + '  <a href="#">'
                                    + '      <i class="fa fa-'+ (i < icons.length ? icons[i] : icons[0]) +'"></i>'
                                    + '      <span class="nav-label">' + item.ModuleName + '</span>'
                                    + '      <span class="fa arrow"></span>'
                                    + '  </a>';
                            //子菜单
                            if(item.Childrens && item.Childrens.length > 0)
                            	c_html = GetChildHtml(item);
                            html += c_html + '</li>';
                        })
                       // showChildMenu(data, $("#side-menu"),1);
                        $("#side-menu").append(html);
                        $('#side-menu').metisMenu();
                    }
                    //关闭加载层
                    layer.closeAll('dialog');
                });
            }
            //暂未使用
            function showChildMenu(item, parent, g) {
                var _grade;
                var _parent;
               
                if(g==2)
                     _grade = $("<ul class='nav nav-third-level'></ul>");
                else
                     _grade = $("<ul class='nav nav-second-level'></ul>");
                item.map(function (d, i) {
                    if (!Y.checkNull(d.Childrens)) {
                        var li = $("<li> <a href='#'><i class=\"fa fa-" + (i < icons.length ? icons[i] : icons[0]) + "\"></i><span class='nav-label'>" + d.ModuleName + "</span><span class'fa arrow'></span></a></li>");
                        $(li).appendTo(parent);
                        if (g == 1)
                            _parent = $(li).last("span");
                        else
                            _parent = $(li).children("ul").last("li");
                        showChildMenu(d.Childrens, _parent, g);
                    }
                    else {
                        $(_grade).append("<li> <a class='J_menuItem' href=" + d.Url + '?ModuleID=' + d.ID + ">" + d.ModuleName + "</a></li>").appendTo(parent);

                    }
                });
            }

            function GetChildHtml(item) {
                var _html = "";
                var t_html = "";
                if (!Y.checkNull(item.Childrens)) {
                    _html += '<ul class="nav nav-second-level">'
                    item.Childrens.map(function (c_item) {
                        _html += '<li>'
                        if (c_item.Type == 1) {
                            _html += '<a href="#">' + c_item.ModuleName + ' <span class="fa arrow"></span></a>';
                          
                        } else {
                            _html += '<a class="J_menuItem" href="' + c_item.Url + '?ModuleID=' + c_item.ID + '">' + c_item.ModuleName + '</a>'
                        }
                        t_html = '';
                        if (c_item.Childrens && c_item.Childrens.length > 0) {
                            t_html += '<ul class="nav nav-third-level">'
                            c_item.Childrens.map(function (t_item) {
                                t_html += '<li>'
                                if (t_item.Type == 1) {
                                    t_html += '<a href="#">' + t_item.ModuleName + ' <span class="fa arrow"></span></a>';
                          
                                } else {
                                    t_html += '<a class="J_menuItem" href="' + t_item.Url + '?ModuleID=' + t_item.ID + '">' + t_item.ModuleName + '</a>';
                                }
                                t_html += '</li>';
                            });
                            t_html += '</ul>';
                        }
                        _html += t_html + '</li>'
                    });
                    _html +='</ul>'
                }
                return _html;
            }
            loadList();
        })
    </script>

</asp:Content>
